//页面加载完成后进行的初始化工作
$(document).ready(function() {

    // Disable certain links in docs
    $('section [href^=#]').click(function(e) {
        e.preventDefault()
    })


    // fix sub nav on scroll
    var $win = $(window)
            , $nav = $('.subnav')
            , navTop = $('.subnav').length && $('.subnav').offset().top - 40
            , isFixed = 0

    processScroll()
    $win.on('scroll', processScroll)
    function processScroll() {
        var i, scrollTop = $win.scrollTop()
        if (scrollTop >= navTop && !isFixed) {
            isFixed = 1
            $nav.addClass('subnav-fixed')
        } else if (scrollTop <= navTop && isFixed) {
            isFixed = 0
            $nav.removeClass('subnav-fixed')
        }
    }

    //提示插件
    $('a[rel=tooltip]').tooltip({
        'placement': 'bottom'
    });



});



/**
 * 将网址添加到收藏夹
 * @param {string} url
 * @param {string} title 
 */
function addFavorite(url, title) {
    if (document.all) {
        window.external.AddFavorite(url, title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else {
        alert("加入收藏失败，请使用Ctrl+D进行添加");
    }
}

